package team.fivez.defaultmanage.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import team.fivez.defaultmanage.domain.Result;
import team.fivez.defaultmanage.service.DefaultReasonService;
import team.fivez.defaultmanage.utils.Utils;

@CrossOrigin
@RestController
@RequestMapping("/defaultReason")
public class DefaultReasonController {

    private final DefaultReasonService defaultReasonService;


    @Autowired
    public DefaultReasonController(DefaultReasonService defaultReasonService) {
        this.defaultReasonService = defaultReasonService;
    }

    @GetMapping("/getUsedReason")
    public Result getUsedList(){
        return Utils.success(defaultReasonService.getUsedList());
    }

    @GetMapping("/getAllReason")
    public Result getAllList(){
        return Utils.success(defaultReasonService.getAllList());
    }

    @GetMapping("/change")
    public Result change(@RequestParam("defaultReasonNumber") int defaultReasonNumber,
                         @RequestParam("usedStatus") int usedStatus){
        defaultReasonService.changeStatus(usedStatus,defaultReasonNumber);
        return Utils.success("ok");
    }

}
